<!DOCTYPE HTML>
<html th:with="title='新增分类',module='/js/app/common/uploadimage.js'">
<head th:include="fragments/header :: header">
</head>
<script type="text/javascript">
	$(function() {
		app = new Vue({
			el : '#app',
			data : {
				appinfo : {}
			},
			methods : {
				closeWin : function() {
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				},
				resetForm : function() {
					$('#app-form')[0].reset();
				},

				getAppId : function() {
					var addr = location.href;
					var index = addr.lastIndexOf('/') + 1;
					var id = addr.substr(index);
					return id;
				},

				getApp : function() {
					var id = this.getAppId();
					$.ajax({
						type : "GET",
						url : '/manager/appversion/get/' + id,
						beforeSend : function() {
						},
						complete : function() {
						},
						error : function(request) {
							alert("Connection error");
						},
						success : function(result) {
							if (result.status == 0) {
								var data = result.data;
								app.appinfo = data;
								new Vue({
									el : '#app-form',
									data : data
								});
							}
						}
					});
				},

				init : function() {
					this.getApp();
					$("#app-form").validate({
						rules : {
							discountIntegral : {
								required : true
							},
							limitIntegral : {
								required : true
							},
							daybegin : {
								required : true
							},
							status : {
								required : true
							},
							dayend : {
								required : true
							}
						},
						onkeyup : false,
						focusCleanup : true,
						success : "valid",
						submitHandler : function(form) {
							var data = $('#app-form').serialize();
							$.ajax({
								type : "POST",
								url : '/manager/appversion/update',
								data : data,
								beforeSend : function() {

								},
								complete : function() {

								},
								error : function(request) {
									layer.alert("系统出错");
								},
								success : function(data) {
									if (data.status == 0) {
										refreshUParentList();
										layer.alert(data.message, function() {
											var index = parent.layer.getFrameIndex(window.name);
											parent.layer.close(index);
										});
									} else {
										layer.alert(data.message);
									}
								}
							});
						}
					});
				}
			}
		});

		app.init();
	});
</script>
<body>
	<div class="page-container">
		<form class="form form-horizontal" id="app-form">
			<input type="hidden" name="id" v-model="id" />
			<input type="hidden" name="createTime" v-model="createTime" />
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">版本编号：</label>
				<div class="formControls col-xs-2 col-sm-2">
					<input type="text" class="input-text size-S" id="vcode" name="vcode" v-model="vcode">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					版本名称：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<input type="text" class="input-text size-S" id="vname" name="vname" v-model="vname">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					上传文件：
				</label>
				<input type="hidden" id="classifyImg" name="classifyImg">
				<div class="col-xs-8 col-sm-8 col-xs-offset-4 col-sm-offset-4" style="margin: 0;">
					<div id="uploader-demo">
						<!--用来存放item-->
						<div id="fileList" class="uploader-list"></div>
						<div id="filePicker" class="btn btn-primary radius">浏览文件</div>
					</div>
				</div>
			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					下载地址：
				</label>
				<div class="formControls col-xs-4 col-sm-4">
					<input type='text' class='input-text size-L' id='downUrl' name='downUrl' v-model="downUrl" disabled>

				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					文件大小：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<input type='text' class='input-text size-L' id='size' name='size' v-model="size" disabled>

				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					app类型：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<span class="select-box">
						<select class="select size-L" id="appType" name="appType" v-model="appType">
							<option value="1">ios</option>
							<option value="2">android</option>
						</select>
					</span>
				</div>

			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					是否强制更新：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<span class="select-box">
						<select class="select size-L" id="isNew" name="isForced" v-model="isForced">
							<option value="0">否</option>
							<option value="1">是</option>
						</select>
					</span>
				</div>

			</div>

			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">
					<span class="c-red">*</span>
					设备类型：
				</label>
				<div class="formControls col-xs-2 col-sm-2">
					<span class="select-box">
						<select class="select size-L" id="deviceType" name="deviceType" v-model="deviceType">
							<option value="0">横屏</option>
							<option value="1">竖屏</option>
							<option value="2">售前APP</option>
						</select>
					</span>
				</div>

			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">更新详情：</label>
				<div class="formControls col-xs-4 col-sm-4">
					<textarea class="textarea" placeholder="请输入本次主要更新内容..." rows="" cols="" name="updateDoc" id="updateDoc" v-model="updateDoc"></textarea>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary size-S radius" type="submit" value="提交">
					<input class="btn btn-primary size-S radius" type="button" onclick="closeWin()" value="关闭">
				</div>
			</div>
		</form>
	</div>


</body>
</html>